package com.jsh.erp.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jsh.erp.datasource.entities.Examine;
import com.jsh.erp.datasource.entities.ExamineItem;
import com.jsh.erp.service.examine.ExamineItemService;
import com.jsh.erp.service.examine.ExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author gonge
 */
@RestController
@RequestMapping("/examineItem")
public class ExamineItemController {

    @Resource
    private ExamineItemService examineItemService;


    @GetMapping("/{id}")
    public ExamineItem getById(@PathVariable Long id) {
        return examineItemService.getById(id);
    }

    @PostMapping
    public boolean save(@RequestBody ExamineItem examineItem) {
        return examineItemService.save(examineItem);
    }

    @PutMapping
    public boolean update(@RequestBody ExamineItem examineItem) {
        return examineItemService.updateById(examineItem);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return examineItemService.removeById(id);
    }

    @GetMapping("/list")
    public List<ExamineItem> list() {
        return examineItemService.list();
    }

    /**
     * 根据Examine DefaultNumber查询出对应的ExamineItem的数据
     * @return
     */
    @GetMapping("/byDefaultNumberWithSumData")
    public List<ExamineItem> selDataByDefaultNumber(
            @RequestParam(value = "defaultNumber") String defaultNumber,
            @RequestParam(value = "returnReason") String returnReason
    ){
        return examineItemService.selDataByDefaultNumber(defaultNumber,returnReason);
    }
}
